﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EFB.Lib;
using EFB.Lib.Entity;

namespace EFB.Web {

    public abstract class BasePage : System.Web.UI.Page {

        public UsuarioEntity SessionUser {
            get {
                return ((UsuarioEntity)ContextHelper.Item("$BasePage.SessionUser"));
            }
            set {
                ContextHelper.WriteItem("$BasePage.SessionUser", value);
            }
        }

        protected String FormatExceptionText(Exception Except) {
            return ContextHelper.FormatExceptionText(Except);
        }

        protected String PageFileName {
            get {
                String[] UrlParts = Request.Url.AbsoluteUri.Split('/');
                return UrlParts[UrlParts.Length - 1];
            }
        }

        protected void Page_Load(object sender, EventArgs e) {
            if (!PageFileName.Equals("Default.aspx", StringComparison.InvariantCultureIgnoreCase) & SessionUser == null) {
                Response.Redirect("~/Default.aspx", true);
            }

        }


    }

}